package org.tjc.net.manager;


import org.tjc.net.manager.config.json.ContextFacade;
import org.tjc.net.manager.config.json.NgMainModule;
import org.tjc.net.manager.config.json.NgServerModule;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: tjc
 * @description
 * @Date Created in 11:03 2020-12-20
 */
public class Engine {
    private NgMainModule context;
    private List<HttpConnector> connectors = new ArrayList<>();

    public Engine(NgMainModule ctx) {
        this.context = ctx;
    }

    public void start() {
        startConnectors();
    }

    private void startConnectors() {
        for (int i = 0; i < context.getServerConfs().size(); i++) {
            ContextFacade facade = new ContextFacade(context, i);
            HttpConnector connector  = new HttpConnector(facade);
            connectors.add(connector);
            connector.start();
        }
    }
}
